/**
 * @filename: MyGenerator.java 2019-10-16
 * @project v0.0.1  V1.0
 * Copyright(c) 2018 BianPeng Co. Ltd.
 * All right reserved.
 */
package com.flying.cattle.mdg;

import java.sql.SQLException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

import com.gitee.flying.cattle.mdg.entity.BasisInfo;
import com.gitee.flying.cattle.mdg.util.EntityInfoUtil;
import com.gitee.flying.cattle.mdg.util.Generator;
import com.gitee.flying.cattle.mdg.util.MySqlToJavaUtil;

/**
 * Copyright: Copyright (c) 2019 
 *
 * <p>说明： 自动生成工具</P>
 * <p>源码地址：https://gitee.com/flying-cattle/mybatis-dsc-generator</P>
 */
public class MyGenerator {
    // 基础信息：项目名、作者、版本
    public static final String PROJECT = "ims";
    public static final String AUTHOR = "Sun Changbo";
    public static final String VERSION = "V1.0";
    // 数据库连接信息：连接URL、用户名、秘密、数据库名
    public static final String URL = "jdbc:mysql://192.168.193.158:3306/famsbate?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL&autoReconnect=true&useSSL=false&failOverReadOnly=false";
    public static final String NAME = "fams";
    public static final String PASS = "fams";
    public static final String DATABASE = "famsbate";
    // todo 需要修改内容 start
    public static final String CLASSCOMMENT = "股票beta系数表";
    public static final String KEY_COLUMN = "STOCK_BETA_ID";
    public static final String TABLE = "RMS_STOCK_BETA";


    public static final String TIME = LocalDate.now().toString();
    public static final String AGILE = new Date().getTime() + "";

    // todo
    public static final String SERVICE_NAME = "rms";


    // 路径信息，分开路径方便聚合工程项目，微服务项目
    public static final String ENTITY_URL = "com.erayt." + SERVICE_NAME + ".domain";
    public static final String VO_URL = "com.erayt." + SERVICE_NAME + ".doview";
    public static final String DAO_URL = "com.erayt." + SERVICE_NAME + ".mapper";
    public static final String XML_URL = "com.erayt." + SERVICE_NAME + ".mapper.xml";
    public static final String SERVICE_URL = "com.erayt." + SERVICE_NAME + ".service";
    public static final String SERVICE_IMPL_URL = "com.erayt." + SERVICE_NAME + ".service.impl";
    public static final String CONTROLLER_URL = "com.erayt." + SERVICE_NAME + ".controller";

    // 前端代码文件
    //是否是Swagger配置
    public static final String IS_SWAGGER = "false";
    public static final String WEB = "com.erayt." + SERVICE_NAME + ".web";


    public static void main(String[] args) {
        String KEY_PROPERTY = MySqlToJavaUtil.changeToJavaFiled(KEY_COLUMN);
        String KEY_PROPERTY_UP = MySqlToJavaUtil.getClassName(KEY_COLUMN);
        BasisInfo bi = new BasisInfo(PROJECT, AUTHOR, VERSION, URL, NAME, PASS, DATABASE, TIME, AGILE, ENTITY_URL, VO_URL,
                DAO_URL, XML_URL, SERVICE_URL, SERVICE_IMPL_URL, CONTROLLER_URL, IS_SWAGGER, KEY_COLUMN, KEY_PROPERTY,
                SERVICE_NAME, WEB, WEB, WEB, WEB, WEB, WEB,KEY_PROPERTY_UP);
        bi.setTable(TABLE);
        bi.setEntityName(MySqlToJavaUtil.getClassName(TABLE));
        bi.setObjectName(MySqlToJavaUtil.changeToJavaFiled(TABLE));
        bi.setEntityComment(CLASSCOMMENT);
        try {
            bi = EntityInfoUtil.getInfo(bi);
            String fileUrl = "D:\\Work\\IDEA\\Mybatis\\mybatis-dsc-generator\\src\\main\\java\\";// 生成文件存放位置
            //开始生成文件
            System.out.println(Generator.createEntity(fileUrl, bi));
            System.out.println(Generator.createVo(fileUrl, bi));
            System.out.println(Generator.createDao(fileUrl, bi));
            System.out.println(Generator.createDaoImpl(fileUrl, bi));
            System.out.println(Generator.createService(fileUrl, bi));
            System.out.println(Generator.createServiceImpl(fileUrl, bi));
            System.out.println(Generator.createController(fileUrl, bi));

            // 前端
            System.out.println(Generator.createLangZh(fileUrl, bi));
            System.out.println(Generator.createValidation(fileUrl, bi));
            System.out.println(Generator.createEditJs(fileUrl, bi));
            System.out.println(Generator.createEditHtml(fileUrl, bi));
            System.out.println(Generator.createListJs(fileUrl, bi));
            System.out.println(Generator.createListHtml(fileUrl, bi));
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
